#ifndef _application_chris_aug_25th_11_26pm_
#define _application_chris_aug_25th_11_26pm_

#ifdef WIN32
#include <windows.h>
#include <SDL.h>
#else
#include <SDL/SDL.h>
#endif

#include <boost/utility.hpp>
#include <GL/gl.h>
#include <GL/glu.h>
#include "DoomIIIMap.h"
#include <string>
#include <iostream>
#include "TextureManager.h"
#include "FirstPersonCamera.h"

namespace Graphics
{
  struct PlaneRenderData {
    std::vector<vmml::Vector3d> points;
    std::vector<vmml::Vector2d> texCoords;
    vmml::Vector3d normal;
    Texture2D *tex;
  };

  class Application : boost::noncopyable
  {
  public:
    Application(const std::string &filename);
    ~Application();

    void InitGL() const;
    void Resize(unsigned int w, unsigned int h, bool ortho = false) const;
    void Update(int milliseconds, Uint8* keyStates, int dx, int dy);
    void Render() const;
  private:
    libPortal::DoomIII::DoomIIIMap d3map;
    Managers::TextureManager texMan;
    void addPlaneToRender(const libPortal::BSPPlane &p);
    std::vector<PlaneRenderData> planes;
    Graphics::FirstPersonCamera cam;
    std::vector<Matrix4d> unitCubes;
  };
  void drawPlane(const PlaneRenderData &d);
  void drawUnitCube();
}

#endif
